define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'user.info/index',
        add_url: 'user.info/add',
        edit_url: 'user.info/edit',
        delete_url: 'user.info/delete',
        export_url: 'user.info/export',
        modify_url: 'user.info/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh',   'export'  ,'delete'],
                cols: [[
                    {type: 'checkbox'},                    {field: 'nickname', title: '用户',templet:function(d){
                    	return "<img style='max-width:25px;' src='"+d.avatar+"'></img>   "+d.nickname;
                    }},                    {field: 'sex', search: 'select', selectList: {"1":"男","2":"女","3":"不显示"}, title: '性别'},
                    {field: 'total_consume_money', title: '累计消费金额'},
                    {field: 'money', title: '余额'},
                    {field: 'commission', title: '佣金'},
                    {field: 'userLevel.id', title: '等级',search:'urlSelect',selectList:{'url':"/user.level/index",'data-fields':'id,name','data-value':'name'},templet:function(d){
                    	return d.userLevel.name;
                    }},                    {field: 'create_time', title: '创建时间',search : 'range'},                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});